package com.hzqy.service.sh_cmcc;

import com.hzqy.persistence.dao.sh_cmcc.BossDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.web.vo.sh_cmcc.BossVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class BossServiceBean extends GenericServiceBean<BossVo, BossDao, Integer> {
	private static final long serialVersionUID = 1L;
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	@Resource
	private BossDao bossDao;

    @Override
    public BossDao getEntityDao() {
        return bossDao;
    }

	/**
	 * 列表获取
	 * @param bossVo
	 * @param curPage
	 * @param pageSize
	 * @return
	 */
	public Map<String,Object> selectBossList(BossVo bossVo, int curPage,
                                                int pageSize) {
        if(!"null".equals(bossVo.getStartDate()) &&!"".equals(bossVo.getStartDate()) ) {
            bossVo.setStartDate(bossVo.getStartDate()+" 00:00:00");
        }
        if(!"null".equals(bossVo.getEndDate()) &&!"".equals(bossVo.getEndDate()) ) {
            bossVo.setEndDate(bossVo.getEndDate()+" 23:59:59");
        }
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = bossDao.findBossCount(bossVo);
		map.put("total", rowCount);
		if(rowCount > 0 && curPage > 0 && pageSize > 0) {
			map.put("firstResult", (curPage-1)*pageSize);
			map.put("maxResults", pageSize);
			map.put("startDate", bossVo.getStartDate());
			map.put("endDate", bossVo.getEndDate());
			map.put("f_scs_type", bossVo.getF_scs_type());
			map.put("UsergroupID", bossVo.getUsergroupID());
			map.put("userid", bossVo.getUserid());
			map.put("EnterpriseName", bossVo.getEnterpriseName());
			List<BossVo> results = bossDao.findBossList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<BossVo>());
		}
		return map;
	}

}
